#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e6+10;
const int mod = 1e9+7;

ll fac[N],inv[N],ans,pp[N];
int n,k;

ll qp(ll x,int t){ll res=1;for(;t;t>>=1,x=x*x%mod)if(t&1)res=res*x%mod;return res;}
ll C(int x,int y){if(x < y || x < 0 || y < 0) return 0;return fac[x] * inv[y] % mod * inv[x-y] % mod;}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,k = in;
	for(int i = (fac[0] = 1);i <= n;i++) fac[i] = fac[i-1] * i % mod; inv[n] = qp(fac[n],mod-2);
	for(int i = n-1;i >= 0;i--) inv[i] = inv[i+1] * (i+1) % mod;
	pp[0] = 2; for(int i = 1;i <= n;i++) pp[i] = pp[i-1] * pp[i-1] % mod;
	for(int i = k;i <= n;i++){
		ans = (ans + ((i - k) & 1 ? -1 : 1) * C(n,i) % mod * C(i,k) % mod * (pp[n-i] - 1) % mod + mod) % mod;
	}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

